package org.julianharty;

/**
 * A very simple LocalService to learn how to create and test them.
 * 
 * This example was inspired by
 * http://www.androidcompetencycenter.com/2009/01/basics-of-android-part-iii-android-services/
 */

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.widget.Toast;

public class LocalCounterService extends Service {
	private int statusCode = 3;
	private MyServiceBinder myServiceBinder = new MyServiceBinder();
	
	@Override
	public IBinder onBind(Intent intent) {
		return myServiceBinder;  // object of the class that implements the interface
	}
	
	public class MyServiceBinder extends Binder implements ICounterService {

		public int getStatusCode() {
			return statusCode++;
		}
	}
	
	@Override
	public void onCreate() {
		super.onCreate();
		Toast t = Toast.makeText(this, "Service created...", Toast.LENGTH_LONG);
		t.show();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		Toast t = Toast.makeText(this, "Service destroyed...", Toast.LENGTH_LONG);
		t.show();
	}
}
